#include "spl.includes.h"
#include "splib.h"

using namespace SPLib;
using namespace SPLib::Windows;
using namespace SPLib::Geom;

#pragma region Protected Methods
void Window::wndProc(Event::WndProcEvent& iEvent)
{
  switch (iEvent.msg)
  {
  case WM_CREATE:
    initWindow();
    iEvent.handled = TRUE;
    iEvent.lResult = TRUE;
    onCreate(Event::WndCreateEvent(iEvent.lParam, &iEvent.lResult));
    --iEvent.lResult;
    break;
  default:
    FrameWnd::wndProc(iEvent);
  }
}

VOID Window::onCreate(Event::WndCreateEvent& iEvent)
{
}

BOOL Window::registerClass(
  HINSTANCE   hInstance,
  PCTSTR      className,
  UINT        classStyle,
  HICON       hIcon,
  HICON       hIconSm,
  HCURSOR     hCursor,
  HBRUSH      hBrush,
  PCTSTR      menuName)
{
  WNDCLASSEX wc;

  // set window class data
  wc.cbSize           = sizeof(wc);
  wc.cbClsExtra       = 0;
  wc.cbWndExtra       = 0;
  wc.lpfnWndProc      = defWndProc;
  wc.hInstance        = !hInstance ? GetModuleHandle(NULL) : hInstance;
  wc.lpszClassName    = className;
  wc.style            = classStyle;
  wc.hIcon            = hIcon;
  wc.hIconSm          = hIconSm;
  wc.hCursor          = !hCursor ? LoadCursor(NULL, IDC_ARROW) : hCursor;
  wc.hbrBackground    = hBrush;
  wc.lpszMenuName     = menuName;

  // register window class
  return RegisterClassEx(&wc);
}
#pragma endregion
